#!/bin/bash

set -e

# 定义源文件目录和目标机器信息
source_dir="static sql *.py"
target_host="xiaochi@124.221.142.162"
target_dir="/home/xiaochi/turing-matrix/"
tar_file="deploy.tar.gz"
set -x

# 创建临时目录并将所有文件压缩成tar文件
tar -czf "$tar_file" $source_dir

# 将tar文件传输到目标机器的/tmp目录
scp "$tar_file" "$target_host:/tmp"

# 在目标机器上解压tar文件并移动到目标目录
ssh "$target_host" "cd $target_dir && tar -xzf /tmp/$tar_file && conda activate zh && python addversion.py ./static/index.html"

# 清理临时文件和目录
rm -rf "$tar_file"